/*
 * Created by JFormDesigner on Thu Sep 09 19:58:37 CST 2021
 */

package com.minelx.woods.pc.form;

import java.awt.event.*;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.awt.*;
import java.util.List;
import javax.swing.*;
import javax.swing.border.*;

/**
 * @author aaa
 */
public class ViewCollectionsDialog extends JDialog {
	public ViewCollectionsDialog(Window owner, JSONArray collections) {
		super(owner, "", ModalityType.APPLICATION_MODAL);
		initComponents();

		// preparing data model
		List<String> collectionNames = collections.toJavaList(String.class);
		DefaultListModel<String> collectionsListModel = new DefaultListModel<>();
		collectionsListModel.addAll(collectionNames);
		collectionsList.setModel(collectionsListModel);
	}

	private void okButtonActionPerformed(ActionEvent e) {
		dispose();
	}

	private void initComponents() {
		// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
		dialogPane = new JPanel();
		contentPanel = new JPanel();
		scrollPane1 = new JScrollPane();
		collectionsList = new JList<>();
		label1 = new JLabel();
		buttonBar = new JPanel();
		okButton = new JButton();

		//======== this ========
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		var contentPane = getContentPane();
		contentPane.setLayout(new BorderLayout());

		//======== dialogPane ========
		{
			dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
			dialogPane.setLayout(new BorderLayout());

			//======== contentPanel ========
			{
				contentPanel.setLayout(new BorderLayout(0, 5));

				//======== scrollPane1 ========
				{

					//---- collectionsList ----
					collectionsList.setFont(new Font("Microsoft JhengHei Light", Font.PLAIN, 22));
					scrollPane1.setViewportView(collectionsList);
				}
				contentPanel.add(scrollPane1, BorderLayout.CENTER);

				//---- label1 ----
				label1.setText("\u666e\u901a\u5b57\u6bb5");
				label1.setFont(new Font("Microsoft JhengHei Light", Font.PLAIN, 30));
				contentPanel.add(label1, BorderLayout.NORTH);
			}
			dialogPane.add(contentPanel, BorderLayout.CENTER);

			//======== buttonBar ========
			{
				buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
				buttonBar.setLayout(new GridBagLayout());
				((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 80};
				((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};

				//---- okButton ----
				okButton.setText("OK, \u8fd8\u53ef\u4ee5");
				okButton.setFont(new Font("Microsoft JhengHei Light", Font.PLAIN, 22));
				okButton.addActionListener(e -> okButtonActionPerformed(e));
				buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
					GridBagConstraints.CENTER, GridBagConstraints.BOTH,
					new Insets(0, 0, 0, 0), 0, 0));
			}
			dialogPane.add(buttonBar, BorderLayout.SOUTH);
		}
		contentPane.add(dialogPane, BorderLayout.CENTER);
		setSize(735, 585);
		setLocationRelativeTo(getOwner());
		// JFormDesigner - End of component initialization  //GEN-END:initComponents
	}

	// JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
	private JPanel dialogPane;
	private JPanel contentPanel;
	private JScrollPane scrollPane1;
	private JList<String> collectionsList;
	private JLabel label1;
	private JPanel buttonBar;
	private JButton okButton;
	// JFormDesigner - End of variables declaration  //GEN-END:variables
}
